#include "ObjectFactory.h"
#include <gl/glut.h>
#include "Game.h"
#include "Model.h"
#include "Aircraft.h"
#include "Tank.h"

extern Game* game;
struct args
{
	float x;
	float y;
	float z;
	int type;
};
void addObjTimer(int value) {
	struct args* arg = reinterpret_cast<struct args*>(value);
	
	//std::cout<<"ADDOBJTIMER"<<std::endl;
	//std::cout<<arg->x<<" "<<arg->y<<" "<<arg->z<<" "<<arg->type<<std::endl;
	switch(arg->type)
	{
	case AIRCRAFT1:
		game->addObject(new Aircraft(arg->x, arg->y, arg->z, 100, game->get_ith_model(AIRCRAFT1)));
		break;
	case AIRCRAFT2:
		game->addObject(new Aircraft(arg->x, arg->y, arg->z, 100, game->get_ith_model(AIRCRAFT2)));
		break;
	case TANK_PROJECT:
		game->addObject(new Tank(arg->x, arg->y, arg->z, 100, game->get_ith_model(TANK_PROJECT)));
		break;
	}
	delete arg;
}
void add_schedule(int timing, float x, float y, float z, MODEL_TYPE mtype)
{
	struct args* argument;
	std::cout<<"ADD_SCHEDULE"<<x<<" "<<y<<" "<<z<<std::endl;
	argument = new args();
	argument->x = x;
	argument->y = y;
	argument->z = z;
	argument->type = mtype;
	glutTimerFunc(timing, addObjTimer, reinterpret_cast<int>(argument));
}